import java.util.*;
public class Day12 {
    public static void main(String[] args) {
        String s = "abc";
    }
    public int findSubstringInWraproundString(String s) {
        int n = s.length();
        int ret = 0;
        int[] dp = new int[n];
        int[] map = new int[26];
        dp[0]=1;
        map[(int)s.charAt(0) - 97] = 1;
        for(int i=1;i<n;i++) {
            char ch = s.charAt(i);
            dp[i]=1;
            if(ch == 'a'&&s.charAt(i-1)=='z' || s.charAt(i-1) + 1 == ch) {
                dp[i]+=dp[i-1];
            }
            if(dp[i] > map[(int)ch-97]) {
                map[(int)ch-97]=dp[i];
            }
        }
        for(int i=0;i<26;i++) {
            ret+=map[i];
        }
        return ret;
    }
}
